package com.api.server.service.impl;

import com.api.server.pojo.Field;
import com.api.server.mapper.FieldMapper;
import com.api.server.service.IFieldService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shi
 * @since 2022-04-28
 */
@Service
public class FieldServiceImpl extends ServiceImpl<FieldMapper, Field> implements IFieldService {

    @Autowired
    private FieldMapper fieldMapper;

    @Override
    public Field message(String fieldnumber) {
        return fieldMapper.selectById(fieldnumber);
    }

    @Override
    public int add(Field field) {
        field.setFieldisfree("是");
        return fieldMapper.insert(field);
    }

    @Override
    public int delete(String id) {
        return fieldMapper.deleteById(id);
    }

    @Override
    public List<Field> equByCdId(String id) {
        return fieldMapper.selectList(new QueryWrapper<Field>().lambda().eq(Field::getFieldvenuenumber,id));
    }

    @Override
    public int updataById(Field field) {
        return fieldMapper.updateById(field);
    }
}
